
#ifndef _Spawner_H_
#define _Spawner_H_

#include "PowerUp.h"
#include "../WorldObject.h"
#include "../Utils/Vector2D.h"
#include "../Utils/Timer.h"
#include "../Ship.h"
#include "../Weapons/Weapon.h"

#include <GL/gl.h>

class Map;

template <class T>
class Spawner : public WorldObject {

  public:
    Spawner(Vector2D pos);
    ~Spawner();

    void render(void);
    void update(void);
    bool active(void);

    bool resolveCollision(Ship *ship);
    bool resolveCollision(Weapon *weapon);
    bool resolveCollision(Map *map);

    WorldObjectType getObjectType(void){ return POWERUP_WOBJECT; }

    Vector2D getPosition(void) const;

  private:
    Vector2D position;
    bool visible;

};


// The method implementations //

template <class T>
Spawner<T>::Spawner(Vector2D pos) : position(pos) {

}

template <class T>
Spawner<T>::~Spawner(){

}

template <class T>
void Spawner<T>::render(void){
    glPushMatrix();

    glTranslatef(position.x, position.y, 0.0f);
    T::renderIcon(0.1f); // TODO something about size?

    glPopMatrix();
}

template <class T>
void Spawner<T>::update(void){

}

template <class T>
bool Spawner<T>::active(void){
    return true;
}

template <class T>
bool Spawner<T>::resolveCollision(Ship *ship){
    return false;
}

template <class T>
bool Spawner<T>::resolveCollision(Weapon *weapon){
    return false;
}

template <class T>
bool Spawner<T>::resolveCollision(Map *map){
    return false;
}

template <class T>
Vector2D Spawner<T>::getPosition(void) const {
    return position;
}



#endif

